﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
using System.Data;
using Comm;
using BusinessFacade;
using Entities;

namespace MedicareNoteManagerWeb.Web
{
    public partial class NotePlanSelect : BasePage
    {
        nm_noteplan_Model model1 = new nm_noteplan_Model();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                model1 = (nm_noteplan_Model)Session["NotePlanModel"];
                BindDrop();
                PageGrid1_Invalidate(sender, e);
                //PageGrid1_SelectedValueChanged(sender, e);
                //lbl_Message.Text = "";
            }
        }
        public void BindDrop()
        {
            FillDropDownList("GetDrop", "AreaID", "AreaName", "请选择区域", this.FindDropArea);
        }
        protected void PageGrid1_SelectedValueChanged(object sender, EventArgs e)
        {
            //Busi_nm_notemessage u = new  Busi_nm_notemessage();
            //nm_notemessage_Model model = u.GetListModel(int.Parse(PageGrid1.SelectedValue));
            
            //txt_Name.Text = model.MoubleName;
            //txt_Content.Value = model.MoubleContent;
            //txt_Explain.Value = model.MoubleExplain;
            //DropArea.SelectedValue = model.MoubleArea.ToString();
        }

        protected void PageGrid1_Invalidate(object sender, EventArgs e)
        {
            Busi_nm_noteplan users = new Busi_nm_noteplan();
            DataTable dt = users.GetList(txt_FindUser.Text.Trim(), int.Parse(FindDropArea.SelectedValue));
            PageGrid1.BindFullDataTable(dt, true);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                PageGrid1_Invalidate(sender, e);
                PageGrid1_SelectedValueChanged(sender, e);
                lbl_Message.Text = "";
            }
            catch (Exception ex)
            {
                lbl_Message.Text = ex.Message.ToString();
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            //PageGrid1.ResetState();
            //txt_Content.Value = "";
            //txt_Explain.Value = "";
            //txt_Name.Text = "";
            //DropArea.SelectedValue = "0";
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button3_Click(object sender, EventArgs e)
        {
            try
            {
                int id = int.Parse(PageGrid1.SelectedValue);
                Busi_nm_notemessage.Delete(id);
                PageGrid1_Invalidate(sender, e);
                PageGrid1_SelectedValueChanged(sender, e);
                MessageBox.Show(this.Page, "删除成功！");
            }
            catch (Exception ex)
            {
               // lbl_Message0.Text = ex.Message;
            }

        }
       
    }
}